package com.im.action;

import java.util.*;

import com.im.entity.*;
import com.im.logic.*;

public class NavigationAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8809271886230298718L;
	private int navi_site = -1;
	private int id;
	
	public List<Link> links = null;
	
	private LinkHandler linkHandler = linkHandlerFac.create();
	
	public String navigation() {
		if(column_name != null && !column_name.isEmpty()) {
			column = colHandler.getColumnByName(column_name);
			List<Link> links = linkHandler.getLinks(column.getId());
			if(links == null || links.size() == 0)
				return "error";
			else {
				column.setObject(links);
				if(navi_site != -1)
					links.get(navi_site).setSiteHere();
				return column.getModel_name();
			}
		} else if(id != 0 && model_name != null && !model_name.isEmpty()) {
			column = new Column();
			List<Link> links = linkHandler.getLinksByParent_link_id(id);
			if(links == null || links.size() == 0)
				return "error";
			else {
				if(navi_site != -1)
					links.get(navi_site).setSiteHere();
				column.setObject(links);
				return model_name;
			}
		} else {
			return "error";
		}
	}

	public int getNavi_site() {
		return navi_site;
	}

	public void setNavi_site(int navi_site) {
		this.navi_site = navi_site;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
}
